package com.ae.shield.common.enchantment.shieldSuffix;

import net.minecraft.enchantment.Enchantment;

import javax.annotation.Nonnull;

public class Specialization extends SuffixBase {
    public Specialization(int rate) {
        super(getRate(rate));
    }

    @Override
    public float levelRate(int level, SuffixProperty property, float rate) {
        switch (property) {
            case CLOSE:
            case REMOTE:
            case MAGIC:
            case OTHER:
                return rate < 1f ? rate - level * 0.05f : rate + level * 0.1f;
            default:
                return rate;
        }
    }

    private static SuffixRate getRate(int i) {
        switch (i) {
            case 0:
                return new SuffixRate()
                        .close(1.3f, 2)
                        .remote(0.8f, 2)
                        .magic(0.8f, 2)
                        .other(0.8f, 2);
            case 1:
                return new SuffixRate()
                        .close(0.8f, 2)
                        .remote(1.3f, 2)
                        .magic(0.8f, 2)
                        .other(0.8f, 2);
            case 2:
                return new SuffixRate()
                        .close(0.8f, 2)
                        .remote(0.8f, 2)
                        .magic(1.3f, 2)
                        .other(0.8f, 2);
            case 3:
                return new SuffixRate()
                        .close(0.8f, 2)
                        .remote(0.8f, 2)
                        .magic(0.8f, 2)
                        .other(1.3f, 2);
            default:
                return new SuffixRate();
        }
    }

    @Override
    protected boolean canApplyTogether(@Nonnull Enchantment enchantment) {
        return !(enchantment instanceof Specialization) && super.canApplyTogether(enchantment);
    }
}
